#include "Panner.h"
#include "PannerWidget.h"
#include "ui_Panner.h"

Panner::Panner(QWidget *parent, const QSize& size) :
    QWidget(parent),
    ui(new Ui::Panner)
{
    ui->setupUi(this);
    ui->m_pannerWidget->slotSizeChanged(size);
    connect(ui->m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotZoomChanged(int)));
    connect(ui->m_pannerWidget, SIGNAL(signalRectangleChanged(QRect)), this, SIGNAL(signalRectangleChanged(QRect)));
}

Panner::~Panner()
{
    delete ui;
}

void Panner::changeEvent(QEvent *e)
{
    QWidget::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
        ui->retranslateUi(this);
        break;
    default:
        break;
    }
}

void Panner::setImage(const QImage& image)
{
    ui->m_pannerWidget->setImage(image);
}

void Panner::slotSizeChanged(const QSize& size)
{
    ui->m_pannerWidget->slotSizeChanged(size);
}

void Panner::slotZoomChanged(int value)
{
    double zoom = value / 100.0;
    ui->m_pannerWidget->setZoom(zoom);
}
